import { createRouter, createWebHashHistory, type RouteRecordRaw } from 'vue-router'
import NProgress from 'nprogress'
import 'nprogress/nprogress.css'
import { pageRouters } from '@/router/modules/page.ts'

const routes: RouteRecordRaw[] = [...pageRouters]

const router = createRouter({
  history: createWebHashHistory(),
  routes
})

// 开始跳转的进度条
router.beforeEach((to, from, next) => {
  NProgress.start()
  console.log('路由前置守卫', to.path, from)
  next()
})

// 结束跳转销毁进度条
router.afterEach(() => {
  NProgress.done()
})

export default router
